home *** CD-ROM | disk | FTP | other *** search
Text File | 2001-03-19 | 22.5 KB | 1,175 lines |
- * $Id: intuition.s 1.1 1999/02/03 04:10:30 jotd Exp jotd $
- **************************************************************************
- * INTUITION-LIBRARY *
- **************************************************************************
- **************************************************************************
- * INITIALIZATION *
- **************************************************************************
-
- POINTER_HEIGHT = 12
- NB_MSG_BUFFERS = 10
-
- INTUIINIT move.l _intbase,d0
- beq .init
- rts
-
- .init
- ;move.l #-_LVOBltBitMapRastPort,d0 ; gfx bad copy/paste??
- move.l #-_LVONextObject,d0
- move.l #242,d1
- lea _intname,a0
- bsr _InitLibrary
- move.l d0,a0
- move.l d0,_intbase
-
- patch _LVOCloseWorkBench(a0),CLOSEWB
- patch _LVOClearDMRequest(A0),MYRTZ
- patch _LVOOpenWindow(A0),_OPENWINDOW
- patch _LVOCloseWindow(A0),_CLOSEWINDOW
- patch _LVOCloseScreen(A0),_CLOSESCREEN ; -- added by JOTD
- patch _LVOShowTitle(A0),MYRTS ; -- dummy, JOTD
- patch _LVOClearPointer(A0),_ClearPointer ; JOTD, monkey island
- patch _LVOClearMenuStrip(A0),MYRTS ; -- added by JOTD
- patch _LVOOpenWorkBench(A0),_OPENWB ; -- added by JOTD
- patch _LVOAlohaWorkbench(A0),MYRTS ; -- added by JOTD
- patch _LVORethinkDisplay(A0),_RethinkDisplay ; -- added by JOTD
- patch _LVORemakeDisplay(A0),MYRTS ; -- added by JOTD
- patch _LVOCurrentTime(A0),_CURRENTTIME ; -- added by JOTD (Theatre of death)
- patch _LVOOpenScreen(A0),_OpenScreen ; -- added by JOTD (Gobliins 2)
- patch _LVOOpenScreenTagList(A0),_OpenScreenTagList
- patch _LVOGetPrefs(A0),_GETPREFS ; -- added by JOTD
- patch _LVOSetPrefs(A0),_SETPREFS ; -- dummy, JOTD
- patch _LVOSetPointer(A0),_SetPointer ; -- JOTD, Monkey Island
- patch _LVOLockIBase(A0),_LOCKIBASE
- patch _LVOMoveScreen(A0),MYRTS ; JOTD, Dummy, Loom
- patch _LVOUnlockIBase(A0),MYRTS ; JOTD, Darkseed
- patch _LVOAllocRemember(A0),_ALLOCREMEMBER ; -- slamtilt
- patch _LVOFreeRemember(A0),_FREEREMEMBER ; -- slamtilt
- patch _LVOMakeScreen(A0),_MAKESCREEN
- patch _LVOScreenToFront(A0),_ScreenToFront ; -- pinball illusions, maniac
- patch _LVOViewAddress(A0),_ViewAddress
- patch _LVOViewPortAddress(A0),_ViewPortAddress ; -- lost vikings
- patch _LVOPubScreenStatus(A0),MYRTS ; -- highseas
- ; patch _LVOQueryOverscan(A0),_QUERYOVERSCAN ; -- subwar, may be unsuccessful!
- ; patch _LVOOpenWindowTagList(A0),_OPENWINDOWTAGLIST ; -- subwar, may be unsuccessful!
- ; patch _LVODisposeObject(A0),MYRTS ; -- subwar
- patch _LVOReportMouse(A0),_ReportMouse ; -- neuromancer
- patch _LVOModifyIDCMP(A0),_ModifyIDCMP ; -- neuromancer
- ; patch _LVOMoveScreen(A0),MYRTS ; -- loom
- patch _LVOWBenchToFront(A0),_WBenchToFront
- patch _LVOWBenchToBack(A0),_WBenchToBack
-
- movem.l D0-A6,-(A7)
-
- ; init ViewLord structure
-
- move.l _intbase,A0
- lea ib_ViewLord(A0),A1
- bsr _InitView ; from graphics lib
-
- ; init active window/screen pointers
-
- move.l _intbase,A0
- clr.l ib_ActiveWindow(A0)
- clr.l ib_ActiveScreen(A0)
-
- ; opens a default screen
-
- move.l A0,A6 ; library base
-
- lea newscreen_struct(pc),A0
- bsr _OpenScreen
- move.l ib_ActiveScreen(A6),A1
- lea newwindow_struct(pc),A0
- move.l A1,nw_Screen(A0)
- bsr _OPENWINDOW
-
- ; opens input.device to process mouse/kbd events
-
- bsr add_input_handler
-
- movem.l (A7)+,D0-A6
- rts
-
- .fail EMUFAIL _LVOOpenLibrary,_intname
-
- ; rem_input_handler, dirty intuition input handler removal
- ; also removes mouse pointer sprite
- ; < A0: intuition interrupt structure
-
- rem_input_handler:
- movem.l D0-A6,-(A7)
- move.l A0,A1
- move.l #$16,D0
- move.l $4.W,A6
- JSRLIB FreeMem
-
- ; move.l _intbase(pc),A6
- ; move.l (ib_ActiveWindow,A6),A0
- ; JSRLIB ClearPointer
-
- move.l _gfxbase(pc),A6
- moveq.l #0,D0
- JSRLIB FreeSprite
-
- movem.l (A7)+,D0-A6
- rts
-
- add_input_handler:
- tst.l _inputhandler ; trick don't insert handler
- bne .exit ; if already one there
-
- ; first; open input.device
-
- lea _inpname(pc),A0
- moveq.l #0,D0
- moveq.l #0,D1
- lea -64(A7),A7
- move.l A7,A1
- move.l $4.W,A6
- JSRLIB OpenDevice
-
- move.l #$16,D0
- move.l #MEMF_CLEAR|MEMF_PUBLIC|MEMF_CLEAR,D1
- JSRLIB AllocMem
- move.l D0,A5 ; A5: input handler structure
-
- lea IntuitionInputHandler(pc),A0
- move.l A0,(IS_CODE,A5)
- move.l _intbase,(IS_DATA,A5)
-
- move.l A7,A1
- move.l A5,(IO_DATA,A1)
-
- move.l (A5),A5 ; node
- move.l #.handlername,(LN_NAME,A5)
- move.b #100,(LN_PRI,A5)
-
- move.w #IND_ADDHANDLER,(IO_COMMAND,A1)
- JSRLIB DoIO
-
- lea 64(A7),A7
- .exit
- rts
- .handlername:
- dc.b "Intuition OSEmu Input Handler",0
- even
-
-
- newscreen_struct:
- dc.w 0,0
- dc.w 320,200
- dc.w 2
- dc.w 1,0
- dc.W 0
- dc.W 0
- dc.l 0 ; font
- dc.l .title
- dc.l 0
- dc.l 0
-
- .title:
- dc.b "title",0
- even
-
- newwindow_struct:
- dc.w 0,0
- dc.w 320,200
- dc.w 0
- dc.l 0,0,0,0
- dc.l .title
- dc.l 0,0
- dc.w 10,10,320,200
- dc.w 0
-
- .title:
- dc.b "title",0
- even
-
- _CursorSpriteData:
- dc.l 0
-
- _CursorSpriteStruct:
- dc.l 0
- dc.w POINTER_HEIGHT
- dc.w 0,0 ; X,Y
- dc.w 0 ; sprite number
-
- ; input handler
-
- IntuitionInputHandler:
- movem.l D0-D7/A0-A6,-(A7)
-
- move.l A1,A4 ; IntuitionBase
-
- ; check if key pressed
-
- cmp.b #IECLASS_RAWKEY,(ie_Class,a0)
- bne.b .norawkey
-
- move.l A0,A5 ; event
-
- bsr _init_event
- tst.l D0
- bne .exit ; ignore it
-
- ; event is processed
-
- move.l #IDCMP_RAWKEY,(im_Class,A3)
- move.w (ie_Code,A5),(im_Code,A3)
- move.w (ie_Qualifier,A5),(im_Qualifier,A3)
-
- ; puts the message in the window message port
-
- move.l $4.W,A6
- move.l (ib_ActiveWindow,A4),A0
- move.l (wd_UserPort,A0),A0
- move.l A3,A1
- JSRLIB PutMsg
-
- bra .exit
-
- .norawkey
-
- cmp.b #IECLASS_RAWMOUSE,(ie_Class,a0)
- bne .exit
- cmp.w #IECODE_NOBUTTON,(ie_Code,a0)
- bne .checkbuttons
-
- ; mouse pointer just moved
-
- move.l (ib_ActiveWindow,A4),A2
-
- move.w (ie_X,a0),D0
- move.w (wd_MouseX,a2),D2
-
- add.w D2,D0
- bmi .leftend
- cmp.w (wd_Width,a2),D0
- bcc .rightend
- .endx
- move.w (ie_Y,a0),D1
- move.w (wd_MouseY,a2),D2
-
- add.w D2,D1
- bmi .upend
- cmp.w (wd_Height,a2),D1
- bcc .downend
- .endy
- ; update window structure
-
- move.w D0,(wd_MouseX,a2)
- move.w D1,(wd_MouseY,a2)
-
- ; moves the sprite
-
- movem.l D0-D1,-(A7)
- sub.l A0,A0 ; no view port!
- lea _CursorSpriteStruct(pc),A1
- move.l _gfxbase(pc),A6
- JSRLIB MoveSprite
- movem.l (A7)+,D0-D1
-
- ; update screen structure
-
- move.l (ib_ActiveScreen,A4),A0
- move.b (wd_XOffset,A2),D3
- ext.w D3
- sub.w D3,D0
- move.w D0,(sc_MouseX,A0)
- move.b (wd_YOffset,A2),D3
- ext.w D3
- sub.w D3,D1
- move.w D1,(sc_MouseY,A0)
-
- bra .exit
- .checkbuttons
- move.l A0,A5 ; event
-
- bsr _init_event
- tst.l D0
- bne .exit ; ignore it
-
- ; event is processed
-
- move.l #IDCMP_MOUSEBUTTONS,(im_Class,A3)
- move.w (ie_Code,A5),(im_Code,A3)
- clr.w (im_Qualifier,A3)
-
- ; puts the message in the window message port
-
- move.l $4.W,A6
- move.l (ib_ActiveWindow,A4),A0
-
- move.l (wd_UserPort,A0),A0
- move.l A3,A1
- JSRLIB PutMsg
-
- .exit:
- movem.l (A7)+,D0-D7/A0-A6
- rts
-
- .upend:
- clr.w D1
- bra .endy
- .downend:
- move.w (wd_Height,a2),D1
- bra .endy
- .leftend:
- clr.w D0
- bra .endx
- .rightend:
- move.w (wd_Width,a2),D0
- bra .endx
-
- ; _init_event, internal function
- ; < A4: intuition base
- ; < A5: event
- ; > A3: IDCMP message
- ; all registers except A4 and A5 are destroyed
-
- _init_event:
-
- lea .messages,A3
- moveq.l #NB_MSG_BUFFERS-1,D0
- move.l #$34,D2 ; sizeof(IntuiMessage)
-
- .loop:
- cmp.b #NT_MESSAGE,(LN_TYPE,A3)
- bne.b .avail
- add.l D2,A3
- dbf D0,.loop
- bra.b .notreplied ; event buffer overflow, discard
-
- .avail:
- move.l D2,(MN_LENGTH,A3)
- move.b #NT_MESSAGE,(LN_TYPE,A3)
-
- move.l (ib_ActiveWindow,A4),A0
- ;; move.l (wd_UserPort,A0),(MN_REPLYPORT,A3)
- clr.l (MN_REPLYPORT,A3) ; no reply port
-
- move.l A0,(im_IDCMPWindow,A3)
- move.l #.deadkey_info,(im_IAddress,A3)
-
- ; composes event mouse X & mouse Y
-
- move.w (wd_MouseX,A0),(im_MouseX,A3)
- move.w (wd_MouseY,A0),(im_MouseY,A3)
-
- ; timestamp the event
-
- lea (im_Seconds,A3),A0
- lea (im_Micros,A3),A1
- move.l A4,A6 ; intuition
- JSRLIB CurrentTime
-
- moveq.l #0,d0
- rts
-
- .notreplied:
- moveq.l #-1,D0
- RTS
-
- .deadkey_info:
- dc.l 0
-
- ; buffers for input events
-
- .messages:
- blk.b $34*NB_MSG_BUFFERS,0
-
- **************************************************************************
- * SCREEN FUNCTIONS *
- **************************************************************************
-
- _ScreenToFront:
- move.l A0,ib_ActiveScreen(A6) ; now this is the active screen
- RTS
-
-
- _MAKESCREEN:
- lea sc_ViewPort(a0),a1
- lea ib_ViewLord(a6),a0
- bsr _MakeVPort ; from graphics.library
- rts
-
- ; OpenScreenTagList()
- ; Written by JOTD
- ; < A0: NewScreen structure
- ; < A1: Tags
- ; > D0: Screen structure
-
-
- _OpenScreenTagList:
- movem.l D1-A6,-(A7)
- cmp.l #0,A0
- bne.b .userstruct
- lea newscreen_struct(pc),A0
- .userstruct:
- .loop
- move.l (A1)+,D1 ; tag
- beq.b .end
-
- move.l (A1)+,D2 ; data
-
- cmp.l #SA_Left,D1
- bne.b .noleft
- move.w D2,ns_LeftEdge(A0)
- bra.b .loop
- .noleft:
- cmp.l #SA_Top,D1
- bne.b .notop
- move.w D2,ns_TopEdge(A0)
- bra.b .loop
- .notop
- cmp.l #SA_Width,D1
- bne.b .nowidth
- move.w D2,ns_Width(A0)
- bra.b .loop
- .nowidth
- cmp.l #SA_Height,D1
- bne.b .noheight
- move.w D2,ns_Height(A0)
- bra.b .loop
- .noheight:
- ; don't care about other tags ATM
- bra.b .loop
- .end:
- bsr _OpenScreen
- movem.l (A7)+,D1-A6
- tst.l D0
- rts
-
- ; OpenScreen()
- ; Written by JOTD
- ; < A0: NewScreen structure
- ; > D0: Screen structure
-
- _OpenScreen:
- movem.l D1-A6,-(A7)
-
- move.l A0,A5 ; newscreen struct
-
- move.l #$15A,D0 ; sizeof(Screen)
- move.l #MEMF_CLEAR,D1
- bsr ForeignAllocMem
- move.l D0,A0 ; screen structure
-
- move.l #($15A/4)-1,D0 ; sizeof(Screen)
- move.l A0,A1
- .tm
- move.l #$EEEEEEEE,(A1)+
- DBF D0,.tm
-
- move.l ib_ActiveScreen(A6),sc_NextScreen(A0) ; other screen saved
- clr.l sc_FirstWindow(A0) ; no windows ATM
- move.w ns_LeftEdge(A5),sc_LeftEdge(A0)
- move.w ns_TopEdge(A5),sc_TopEdge(A0)
- move.w ns_Width(A5),sc_Width(A0)
- move.w ns_Height(A5),sc_Height(A0)
- move.w ns_Type(A5),sc_Flags(A0)
- clr.w sc_MouseX(A0)
- clr.w sc_MouseY(A0)
- move.l #_TOPAZ8FONT,sc_Font(A0)
-
- move.b ns_DetailPen(A5),sc_DetailPen(A0)
- move.b ns_BlockPen(A5),sc_BlockPen(A0)
-
- move.l ns_DefaultTitle(A5),sc_DefaultTitle(A0)
-
- ; initializes ViewPort structure
-
- move.l A0,A4 ; screen structure
- lea sc_ViewPort(A4),A0
- bsr _InitVPort
- lea sc_ViewPort(A4),A0
- move.l #_INITRASINFO,vp_RasInfo(A0) ; share with graphics.library rasinfo
-
- ; initializes RastPort structure
-
- lea sc_RastPort(A4),A1
- bsr _InitRastPort
-
- ; initializes bitmap
-
- lea sc_BitMap(A4),A0
- move.w ns_Depth(A5),D0
- move.w ns_Width(A5),D1
- move.w ns_Height(A5),D2
- bsr _InitBitMap
-
- ; allocates bitplanes
-
- lea sc_BitMap(A4),A0
- bsr _internal_AllocBitPlanes
-
- ; copies bitmap to rastport.bitmap
-
- lea sc_BitMap(A4),A0
- lea sc_RastPort(A4),A1
- lea rp_BitMap(A1),A1
- move.l #9,D0
- .copy
- move.l (A0)+,(A1)+
- dbf D0,.copy
-
- lea sc_BitMap(A4),A0
- move.l sc_ViewPort+vp_RasInfo(A4),A3 ; pointer on rasinfo struct
- move.l A0,(ri_BitMap,A3) ; puts the bitmap into rasinfo struct
-
- ; makes the view
-
- ; lea (ib_ViewLord,A6),A0 ; view
- ; lea (sc_ViewPort,A4),A1
- ; bsr _MakeVPort
-
- ifeq 1
- ; gets colormap
-
- moveq.l #1,D0
- move.w ns_Depth(A5),D1
- lsl.w D1,D0 ; computes number of colors
-
- bsr _GETCOLORMAP
- lea sc_ViewPort(A4),A0
- move.l D0,vp_ColorMap(A0)
- endif
-
-
- move.l A4,ib_ActiveScreen(A6) ; sets active screen
- move.l a4,ib_FirstScreen(A6) ; sets first screen (Harry)
-
- move.l A4,D0 ; return value
-
- movem.l (A7)+,D1-A6
-
- rts
-
- _OPENWB:
- moveq.l #1,D0 ; non-NULL
- rts
-
- ISCLOSED
- dc.l 0 ; added by JOTD
-
- ;since there is no workbench, closing should awlays return 0 for success
- ;but some programs loop until the routine returns false (ok the wb is closed)
-
- CLOSEWB
- movem.l A0,-(A7)
- lea ISCLOSED(pc),A0
- move.l (A0),D0 ; first time returns 0, and 1 afterwards
- move.l #1,(A0)
- movem.l (A7)+,A0
- RTS
-
- ; < A0: PrefBuffer
- ; < D0: Size
- ; < D1: notify
- ; > D0: returns PrefBuffer
-
- _SETPREFS:
- lea prefsdata(pc),A1
-
- move.l D0,D1
- subq.l #1,D1
-
- move.l A0,D0 ; prepare return value
-
- .copy
- move.b (A0)+,(A1)+
- dbf D1,.copy
- rts
-
- ; < A0: PrefBuffer
- ; < D0: Size
- ; > D0: returns PrefBuffer
-
- _GETPREFS
- bsr .read_prefs
-
- lea prefsdata(pc),A1
-
- move.l D0,D1
- subq.l #1,D1
- .copy
- move.b (A1)+,(A0)+
- dbf D1,.copy
- rts
-
- .read_prefs:
- movem.l D0-A6,-(A7)
- move.l _dosbase(pc),A6
- move.l #MODE_OLDFILE,D2
- move.l #.sysconf_name,D1
- JSRLIB Open
- move.l D0,D6
- bne.b .ok
-
- ; not found in devs, try in root directory
-
- move.l #MODE_OLDFILE,D2
- move.l #.sysconf_name2,D1
- JSRLIB Open
- move.l D0,D6
- beq.b .out
-
- .ok
- move.l D6,D1
- move.l #prefsdata,D2
- move.l #232,D3
- JSRLIB Read
-
- move.l D6,D1
- JSRLIB Close
- .out
- movem.l (A7)+,D0-A6
- rts
-
- .sysconf_name:
- dc.b ":devs/system-configuration",0
- even
-
- .sysconf_name2:
- dc.b ":system-configuration",0
- even
-
- _OPENWINDOW
- MOVE.L A0,-(A7)
- MOVE.L #$88,D0
- MOVE.L #MEMF_CLEAR,D1
- bsr ForeignAllocMem
- MOVE.L D0,A1
-
- move.l #($88/4)-1,D0 ; sizeof(Window)
- move.l A1,A0
- .tm
- move.l #$EEEEEEEE,(A0)+
- DBF D0,.tm
-
- ; allocates memory for message & rastport
- ; (as OSEmu is rather greedy in memory, let's group both structures)
-
- movem.l A1/A6,-(A7)
- MOVE.L #$64,D0
- MOVE.L #MEMF_CLEAR,D1
- move.l $4.W,A6
- JSRLIB AllocMem
- movem.l (A7)+,A1/A6
-
- MOVE.L D0,wd_RPort(A1) ; stores rastport
- move.l A1,-(A7)
- move.l D0,A1
- bsr _InitRastPort
-
- move.l A6,-(A7)
- move.l $4.W,A6
- JSRLIB CreateMsgPort ; initializes window message port
- move.l (A7)+,A6
-
- move.l (A7),A1
-
- move.l D0,wd_UserPort(A1) ; user port to add to ports list
-
- ; call AddPort
-
- MOVE.L wd_UserPort(A1),A1
-
- move.l A6,-(A7)
- move.l $4.W,A6
- JSRLIB AddPort
- move.l (A7)+,A6
-
- MOVE.L (A7)+,A1
-
- MOVE.L (A7)+,A0
-
- MOVE.L nw_LeftEdge(A0),wd_LeftEdge(A1)
- MOVE.L nw_TopEdge(A0),wd_TopEdge(A1)
- MOVE.L nw_Width(A0),wd_Width(A1)
- MOVE.L nw_Screen(A0),wd_WScreen(A1)
- MOVE.W nw_DetailPen(A0),wd_DetailPen(A1)
- MOVE.L nw_IDCMPFlags(A0),wd_IDCMPFlags(A1)
- MOVE.L nw_Flags(A0),wd_Flags(A1)
- MOVE.L nw_FirstGadget(A0),wd_FirstGadget(A1)
- MOVE.L nw_CheckMark(A0),wd_CheckMark(A1)
- MOVE.L nw_Title(A0),wd_Title(A1)
- MOVE.L nw_Screen(A0),wd_WScreen(A1)
- MOVE.L nw_MinWidth(A0),wd_MinWidth(A1)
- MOVE.L nw_MaxWidth(A0),wd_MaxWidth(A1)
- MOVE.L nw_MinHeight(A0),wd_MinHeight(A1)
- MOVE.L nw_MaxHeight(A0),wd_MaxHeight(A1)
-
- clr.b wd_BorderLeft(A1)
- clr.b wd_BorderTop(A1)
- clr.b wd_BorderRight(A1)
- clr.b wd_BorderBottom(A1)
-
- move.l A1,ib_ActiveWindow(A6) ; sets intuition active window
-
- move.l A1,D0 ; return value
-
- move.l wd_WScreen(A1),A1 ; parent screen
- move.l D0,sc_FirstWindow(A1) ; this window is the first window
-
- move.l D0,A1
- ; creates/allocates sprite pointer
-
- ; pointer starts at 0
-
- move.w #0,(wd_MouseY,A1)
- move.w #0,(wd_MouseX,A1)
-
- RTS
-
- ; < A1: window pointer
- create_sprite_pointer:
- tst.l _CursorSpriteData
- bne .end
-
- movem.l D0-A6,-(A7)
-
- move.l A0,A3 ; window pointer there
-
- move.l #4+(POINTER_HEIGHT*2*2)+4,D0
- move.l #MEMF_CHIP|MEMF_CLEAR,D1
- move.l $4.W,A6
- JSRLIB AllocMem
- move.l D0,_CursorSpriteData
- beq .fail ; could not allocate memory
-
- move.l D0,A2
-
- ; gets next sprite
-
- lea _CursorSpriteStruct(pc),A1
- moveq.l #-1,D0 ; any
- move.l _gfxbase(pc),A6
- JSRLIB GetSprite
- tst.l D0
- bmi .fail ; could not allocate a sprite
-
- lea .sprite_data(pc),A0
- move.l A2,A1
- moveq.l #POINTER_HEIGHT*2-1,D0
- .pcopy
- move.l (A0)+,(A1)+
- dbf D0,.pcopy
-
- lea _CursorSpriteStruct(pc),A1
- sub.l A0,A0 ; no view port!
- move.w #POINTER_HEIGHT,(ss_height,A1)
- JSRLIB ChangeSprite
-
- ; sets definitions in window structure
-
- move.l A2,(wd_Pointer,A3)
- move.w #POINTER_HEIGHT,(wd_PtrHeight,A3)
- move.w #$10,(wd_PtrWidth,A3)
- clr.b (wd_XOffset,A3)
- clr.b (wd_YOffset,A3)
-
- ; moves sprite according to window struct
-
- lea _CursorSpriteStruct(pc),A1
- sub.l A0,A0
- move.w (wd_MouseX,A3),D0
- move.w (wd_MouseY,A3),D1
- JSRLIB MoveSprite
-
- movem.l (A7)+,D0-A6
- .end
- rts
-
- .fail EMUFAIL _LVOOpenWindow,_intname
- .sprite_data:
- dc.w $1C0,$80
- dc.w $1C0,$80
- dc.w $1C0,$80
- dc.w $3E0,$1C0
- dc.w $5D0,$80
- dc.w $3E3E,$410
- dc.w $3E3E,$3E3E
- dc.w $3E3E,$410
- dc.w $5D0,$80
- dc.w $3E0,$1C0
- dc.w $1C0,$80
- dc.w $1C0,$80
-
- dc.w $1C0,$80
- dc.w $1C0,$80
- dc.w $1C0,$80
- dc.w $3E0,$1C0
- dc.w $5D0,$80
- dc.w $FFFF,$410
- dc.w $FFFF,$FFFF
- dc.w $FFFF,$410
- dc.w $5D0,$80
- dc.w $3E0,$1C0
- dc.w $1C0,$80
- dc.w $1C0,$80
-
-
- ; close screen, untested
- ; < A0: screen
- _CLOSESCREEN
- move.l A0,A1
- lea sc_BitMap(A1),A0
-
- ; frees bitplanes
-
- bsr _internal_FreeBitPlanes
-
- ; frees screen structure
-
- move.l #$15A,D0 ; sizeof(Screen)
- bsr ForeignFreeMem
- rts
-
-
- ; < A0: window
- _CLOSEWINDOW
- MOVE.L A0,A1
- MOVE.L #$88,D0
-
- move.l wd_WScreen(A1),A0 ; parent screen
- clr.l sc_FirstWindow(A0) ; no more windows on screen
-
- movem.l A6,-(A7)
- move.l $4.W,A6
-
- ; removes port from ports list
-
- movem.l D0/A1,-(A7)
- move.l wd_UserPort(A1),A1 ; user port to remove from ports list
- JSRLIB RemPort
- movem.l (A7)+,D0/A1
-
- ; frees rastport memory
-
- movem.l D0/A1,-(A7)
- MOVE.L #$64,D0
- move.l wd_RPort(A1),A1
- JSRLIB FreeMem
- movem.l (A7)+,D0/A1
-
- ; deletes message port
-
- movem.l D0/A1,-(A7)
- move.l wd_RPort(A1),A0
- JSRLIB DeleteMsgPort
- movem.l (A7)+,D0/A1
-
- ; frees window structure
-
- JSRLIB FreeMem
- movem.l (A7)+,A6
-
- RTS
-
- _LOCKIBASE MOVE.L #'MYLK',D0
- RTS
-
- **************************************************************************
- * ICON-LIBRARY *
- **************************************************************************
- **************************************************************************
- * INITIALIZATION *
- **************************************************************************
-
- ILIBINIT move.l _ilibbase,d0
- beq .init
- rts
-
- .init move.l #-_LVOBumpRevision,d0
- move.l #LIB_SIZE,D1
- lea _ilibname,a0
- bsr _InitLibrary
- move.l d0,a0
- move.l d0,_ilibbase
-
- patch _LVOGetDiskObject(a0),MYRTZ
-
- rts
-
-
- **************************************************************************
- * LAYERS-LIBRARY *
- **************************************************************************
- **************************************************************************
- * INITIALIZATION *
- **************************************************************************
-
- LAYERSINIT move.l _laybase,d0
- beq .init
- rts
-
- .init move.l #-_LVOMoveLayerInFrontOf,d0
- move.l #LIB_SIZE,D1
- lea _layname,a0
- bsr _InitLibrary
- move.l d0,a0
- move.l d0,_laybase
-
- rts
-
- ; mathffp, mathtrans stuff relocated in specific files
-
- _CURRENTTIME: ; added by JOTD
- move.l sec_timer,(A0)
- move.l microsec_timer,(A1)
- rts
-
- ; AllocRemember (needed by SlamTilt)
- ;
- ; <A0: struct Remember to allocate
- ; <D0: size
- ; <D1: flags
- ; >D0: allocated block
- ; >(A0): "structure"
-
- _ALLOCREMEMBER:
- movem.l D2/A2,-(A7)
-
- bsr .find_free_node
-
- add.l #$10,D0 ; adds $10 bytes to the required size
- ; (4 is not enough for proper alignment)
- move.l D0,D2 ; save size
-
- ; perform alloc
-
- move.l A0,-(A7)
- bsr ForeignAllocMem
- move.l (A7)+,A0
-
- move.l D0,(A0) ; initialize structure
- beq.b .fail ; allocation failed
- move.l D0,A2
-
- clr.l (A2) ; set NEXT to NULL
- move.l D2,(4,A2) ; set size as second longword of the allocated buffer
- ; A0 points on allocated block with size info
- add.l #$10,D0 ; D0 points on allocated buffer
- .end
- movem.l (A7)+,D2/A2
- rts
- .fail
- bra.b .end
-
- ;< A0: struct Remember
- ;> A0: free node buffer
-
- .find_free_node:
- .loop
- tst.l (A0) ; next available?
- beq.b .found ; yep
- move.l (A0),A0 ; next please
- bra.b .loop
- .found:
- rts
-
- ; <A0: RememberKey
- ; <D0:= 0: just free the structure
- ; !=0: free struct & free memory
-
- _FREEREMEMBER:
- tst.l (A0)
- beq.b .exit
- move.l (A0),A1
- clr.l (A0) ; zero the struct Remember * pointer
-
- tst.l D0
- beq.b .exit ; FALSE: do nothing
-
- move.l A1,A0 ; restore A0 value
- .loop
- cmp.l #0,A0 ; end of list?
- beq.b .exit
- move.l A0,A1 ; buffer
- move.l (4,A0),D0 ; size
- move.l (A0),A0 ; next
-
- move.l A0,-(A7)
- bsr ForeignFreeMem
- move.l (A7)+,A0
-
- bra.b .loop
- .exit
- rts
-
- ; < A0: window
- ; > D0: view port address of the screen
- ; (matches AROS implementation, and probably original OS too)
-
- _ViewPortAddress:
- move.l wd_WScreen(A0),A0 ; the screen of the window
- lea sc_ViewPort(a0),A0 ; viewport address
- move.l A0,D0 ; in D0
- rts
-
- ; < D0: view
- ; (matches AROS implementation, and probably original OS too)
-
- _ViewAddress:
- lea ib_ViewLord(A6),A0
- move.l A0,D0
- rts
-
- ; dummy, always returns true
-
- _QUERYOVERSCAN:
- moveq #-1,D0 ; success
- rts
-
- ; dummy, returns initialization screen
-
- _OPENWINDOWTAGLIST:
- move.l ib_ActiveWindow(A6),D0
- rts
-
- ; added by JOTD
- ; First calls MakeVPort
- ; then MrgCop
- ; then LoadView
-
- _RethinkDisplay
- movem.l a2/a5/a6,-(A7)
- move.l A6,A5 ; save intuition base
- move.l (ib_ActiveScreen,A5),A2
- move.l _gfxbase,A6 ; I hope gfxbase is active!!
- lea (sc_ViewPort,a2),A1 ; ViewPort structure
- lea (ib_ViewLord,A5),A0 ; user intuition view structure
- move.l A1,(v_ViewPort,A0) ; set viewport in view
- JSRLIB MakeVPort ; build copperlist
-
- lea (ib_ViewLord,A5),A1
- JSRLIB MrgCop ; merges copperlists
-
- lea (ib_ViewLord,A5),A1
- JSRLIB LoadView ; loads the view
-
- movem.l (A7)+,a2/a5/a6
- rts
-
- _internal_AllocBitPlanes: ; A0: bitmap
- movem.l D0-A6,-(A7)
- move.w (bm_BytesPerRow,a0),d1
- move.w (bm_Rows,a0),d2
- mulu d1,d2
- moveq #0,D3
- move.b (bm_Depth,A0),D3
- lea (bm_Planes,A0),A2
- subq.l #1,D3
- move.l $4.W,A6
- .allocloop:
- move.l D2,D0 ; size
- move.l #MEMF_CHIP|MEMF_CLEAR,D1 ; reqs
- JSRLIB AllocMem
- move.l D0,(A2)+
- beq.b .fail
- dbf D3,.allocloop
-
- movem.l (A7)+,D0-A6
- rts
-
- .fail
- EMUFAIL _LVOInitBitMap,_gfxname
-
- _internal_FreeBitPlanes: ; A0: bitmap
- movem.l D0-A6,-(A7)
- move.w (bm_BytesPerRow,a0),d1
- move.w (bm_Rows,a0),d2
- mulu d1,d2
- moveq #0,D3
- move.b (bm_Depth,A0),D3
- lea (bm_Planes,A0),A2
- subq.l #1,D3
- move.l $4.W,A6
- .allocloop:
- move.l (A2),A1 ; address
- move.l D2,D0 ; size
- JSRLIB FreeMem
- move.l #$DEADC0DE,(A2)+ ; trash it, safer
- dbf D3,.allocloop
- movem.l (A7)+,D0-A6
- rts
-
- ; ClearPointer, added by JOTD
-
- _ClearPointer:
- move.l _CursorSpriteData(pc),D0
- beq.b .end
- move.l D0,A0
- moveq.l #POINTER_HEIGHT*2-1,D0
- .loop
- clr.l (a0)+
- dbf D0,.loop
- .end
- rts
-
- ; SetPointer, added by JOTD
-
- _SetPointer:
- bsr create_sprite_pointer
-
- move.l A1,(wd_Pointer,A0)
- move.w D0,(wd_PtrHeight,A0)
- move.w D1,(wd_PtrWidth,A0)
- move.b D2,(wd_XOffset,A0)
- move.b D3,(wd_YOffset,A0)
-
- movem.l A2/A6,-(A7)
-
- move.l A1,A2
- lea _CursorSpriteStruct(pc),A1
- clr.l (A1)
- clr.w (ss_num,A1) ; first sprite
- move.w D0,(ss_height,A1)
-
- move.w (wd_MouseX,A0),D0
- addx.b D2,D0
- move.w D0,(ss_x,A1)
- move.w (wd_MouseY,A0),D0
- addx.b D3,D0
- move.w D0,(ss_y,A1)
-
- sub.l A0,A0 ; no view port!
- move.l _gfxbase(pc),A6
- JSRLIB ChangeSprite
-
- movem.l (A7)+,A2/A6
- rts
-
-
- ; ModifyIDCMP (JOTD)
- ; < A0: window
- ; < D0: new flags
-
- _ModifyIDCMP:
- MOVE.L D0,wd_IDCMPFlags(A0)
- moveq.l #1,D0
- rts
-
- _WBenchToFront
- _WBenchToBack
- moveq.l #-1,D0
- RTS
-
- ; ReportMouse (JOTD)
- ; < A0: window
- ; < D0: boolean
-
- _ReportMouse
- or.w #WFLG_REPORTMOUSE,(wd_Flags,A0)
- tst.l D0
- bne.b .exit
- and.w #~WFLG_REPORTMOUSE,(wd_Flags,A0)
- .exit
- rts
- prefsdata:
- include "prefs.s"
- even
-
-